import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
import routes from './routes';

const router = createRouter({
	history: createWebHistory(),
	routes: routes,
  scrollBehavior(to, from, savedPosition) { // 自动滚动到左侧顶部
    if (savedPosition) { // 点击回退/前进按钮
      return savedPosition 
    } else { // 跳转路由
      return { left: 0, top: 0 }  // vue2中是 {x: 0, y: 0}
    }
  },
})

// 导出路由
export default router;


/* 
new VueRouter({
  mode: 'hash' // history
})
*/